<%@ page import="static status.UserAuthority.ADMIN_AUTHORITY" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>线上社区超市首页</title>
    <%@include file="/pages/common/head_info.jsp"%>
    <link type="text/css" rel="stylesheet" href="static/css/index.css" >
    <link type="text/css" rel="stylesheet" href="static/css/head.css" >

    <script type="text/javascript">
        $(function () {

            $("button.addToCart").click(function () {

                if (${empty sessionScope.userId}) {
                    alert("请先登录账号");
                } else {
                    let bookId = $(this).attr("bookId");
                    let bookName = $(this).attr("bookName");
                    let bookPrice = $(this).attr("bookPrice");

                    location.href = "cartServlet?action=addBook&bookId=" + bookId + "&bookName=" + bookName + "&bookPrice=" + bookPrice
                        + "&pageNumber=" +${requestScope.page.pageNumber};
                }
            });

            $("a.cartClass").click(function () {

                if (${empty sessionScope.userId}) {
                    alert("请先登录账号");
                    return false;
                }
            });

        })

    </script>
</head>
<body>

<div class="head">
    <div class="logo">
        <h1><a href="pages/client/index.jsp">线上社区超市</a></h1>
    </div>
    <div>
        <c:if test="${empty sessionScope.userId}">
            <div class="userdata" style="width: 300px;margin-right: 250px;">
                <a href="pages/user/regist.jsp"><h3>注册</h3></a>
                <a href="pages/user/login.jsp"><h3>登录</h3></a>
            </div>
        </c:if>
        <c:if test="${not empty sessionScope.userId}">
            <div class="userdata" style="width: 400px;margin-right: 150px;">
                <a href="userServlet?action=logout"><h3 style="font-size: 10px;">注销</h3></a>
                <a href="orderServlet?action=showMyOrder"><h3 style="font-size: 10px;">我的订单</h3></a>
                <a href="pages/user/userdata.jsp"><h3 style="font-size: 10px;">个人信息</h3></a>
            </div>
        </c:if>
    </div>

</div>
<div class="index-box">
    <div class="classification">
        <div class="fication">
            <span>产品分类</span>
        </div>
        <div>
            <ul>
                <a href="client/bookServlet?action=page&classify=t_goods"><li>>  全部</li></a>
                <a href="client/bookServlet?action=page&classify=t_vegetables"><li>>  蔬菜</li></a>
                <a href="client/bookServlet?action=page&classify=t_meat"><li>>  肉类</li></a>
                <a href="client/bookServlet?action=page&classify=t_fruit"><li>>  水果</li></a>
                <a href="client/bookServlet?action=page&classify=t_oil"><li>>  粮油</li></a>
                <a href="client/bookServlet?action=page&classify=t_snacks"><li>>  零食</li></a>
                <a href="client/bookServlet?action=page&classify=t_clothes"><li>>  衣服</li></a>
            </ul>
        </div>
    </div>

    <div class="advertisement" style="margin-left:15px;">
        <div class="adv1">
            <a href=""><img src="static/img/gg1.jpg" alt=""></a>
            <a href=""><img src="static/img/gg2.jpg" alt=""></a>
            <a href=""><img src="static/img/gg3.jpg" alt=""></a>
        </div>
        <div class="adv2">
            <a href=""><img src="static/img/dgg1.jpg" alt=""></a>
            <a href=""><img src="static/img/dgg2.jpg" alt=""></a>
        </div>

    </div>

    <div class="ShoppingCart">
        <a class="cartClass" href="cartServlet?action=getCartInfo">
            <span>购物车</span>
            <img src="static/img/shoppingcart.jpg" alt="">
        </a>
    </div>

</div>

</body>
</html>